<?php
/* 
* [***********************]
* @author: mazhenyu[houdunwangmzy@163.com]
* @Date:   2014-07-11 20:36:05
* @Last Modified time: 2014-07-13 19:51:56
*/
class LoginControl extends Control{
	public function index(){
		if(IS_POST){
			if(Q('post.code', '', 'strtoupper') != session('code')) $this->error('验证码错误');
			$stat = Rbac::login(Q('post.username'),Q('post.password', '', 'md5'),'admin');
			//如果登录有错
			if(!$stat) $this->error(Rbac::$error);
			//登录成功
			$this->success('登录成功',U('Index/index'));
		}
		$this->display();
	}


	public function out(){
		session(NULL);
		$this->success('退出成功',U('Login/index'));
	}


	/**
	 * [code 显示验证码]
	 * @return [type] [description]
	 */
	public function code(){
		// C('CODE_LEN',4);
		$code = new Code();
		$code->show();
	}

}
?>
